package cn.wangliang181230.boot.web.autoconfiguration;

import cn.wangliang181230.boot.web.properties.MyTestProperties;
import cn.wangliang181230.boot.web.springbean.IMyBean;
import cn.wangliang181230.boot.web.springbean.MyBean1;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;

//@ConditionalOnProperty(value = "my.autoconfig.type", havingValue = "1", matchIfMissing = true)
//@ConditionalOnProperty(prefix = "my.autoconfig", value = "type", havingValue = "1", matchIfMissing = true)
public class MyBean1AutoConfiguration {

	public MyBean1AutoConfiguration() {
		System.out.println("MyTestAutoConfiguration1: constructor");
	}


	@Bean
	@ConditionalOnMissingBean // 无参时，默认取方法出参类型
	//@ConditionalOnMissingBean(Xxxx.class) // 指定某一个或多个类型的Bean不存在时，加载
	public IMyBean myBean1(MyTestProperties properties) {
		System.out.println("MyTestAutoConfiguration1: create bean: MyBean1");
		return new MyBean1(properties);
	}

}
